const {Banner} = require("../model/index");
exports.getBanner = async ()=>{

    const banner = await  Banner.find({
        name:"banner"
    })
    const background = await Banner.findOne({name:"b"})

    return {
        banner,
        background
    };
}

exports.addBanner = async(thumb = '',imgUrl ="",name = 'banner')=>{
    const result = await Banner.create({
        thumb,
        imgUrl,
        name
    })
    return result

}

exports.upBanner = async (_id,thumb,imgUrl) => {
    const result = await Banner.updateOne({_id},{
        $set:{
            thumb,
            imgUrl
        }
    })
    return result
}


exports.delBanner = async (_id)=>{

    const result = await Banner.deleteOne({_id});

    return result;
}


